import net.sivashov.grailssample.DataSourceDefinition

class BootStrap {

    def init = { servletContext ->
        if (!DataSourceDefinition.findByName('ds1')) {
            new DataSourceDefinition(
                    name: 'ds1',
                    datasourceUrl: 'jdbc:mysql://localhost:3306/ds1',
                    username: 'root',
                    password: 'root'
            ).save()
        }

        if (!DataSourceDefinition.findByName('ds2')) {
            new DataSourceDefinition(
                    name: 'ds2',
                    datasourceUrl: 'jdbc:mysql://localhost:3306/ds2',
                    username: 'root',
                    password: 'root'
            ).save()
        }
//        Book.withTransaction {
//            new Book(
//                name: 'book2',
//                author: 'author2'
//            ).save()
//        }

    }
    def destroy = {
    }
}
